home *** CD-ROM | disk | FTP | other *** search
- Path: csun.edu!hbmus009
- From: hbmus009@csun.edu (christopher johnson)
- Newsgroups: comp.lang.c
- Subject: Re: What dose a DLL file do?
- Date: 2 Mar 1996 21:58:39 GMT
- Organization: California State University, Northridge
- Message-ID: <4hagaf$9id@dewey.csun.edu>
- References: <4h8b73$7ua@coranto.ucs.mun.ca>
- NNTP-Posting-Host: louie.csun.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Matthew Smyth (ybf1037@InfoNET.st-johns.nf.ca) wrote:
- > I was wondering what exactly dose a DLL file do?
-
- DLL stands for Dynamic Link Library. These are a special kind of library
- that doesn't get statically linked into your programs. The final linking
- process happens when you execute a program that will make use of a
- particular DLL. Ok, that didn't make a lot of sense to anyone that
- doesn't know what a DLL is in the first place. Let me try again.
-
- A DLL is a collection of functions (a library). Lets have an example dll
- with one exported function say,
-
- int FAR PASCAL _export nSucc(int n)
-
- Which returns the value n + 1. I'll draw a picture:
-
- example.dll
- +-------------------------------------+
- | |
- | int FAR PASCAL _export nSucc(int n) |
- | |
- +-------------------------------------+
-
- Ok, now you have a program where you want to make use of this function
- nSucc(). To do so, you include the header file (probably something like
- example.h). Then you link your program to the EXPORT library of
- example.dll (not the actual library itself). A copy of the function
- nSucc() doesn't get included in your compiled code. What does get included
- is a set of instructions telling the program to at runtime load
- example.dll and use the nSucc function in that module. So we might write
-
- #include "example.h"
-
- main()
- {
- int n;
-
- for (n = 0; n < 5; n = nSucc(n)) /* Makes a call to example.dll */
- printf("This program does nothing useful.\n");
- }
-
- That is why when you try to run something like Netscape and you don't have
- a copy of winsock.dll, it gives you that error message. Netscape trys to
- load winsock.dll at runtime, and if it can't do so, all of the calls to
- functions inside of winsock.dll will create General Protection Faults.
- Therefore it aborts the program.
-
- So why would you want to use a DLL? Lots o reasons, but someone else
- should perhaps have a go at answering that. God knows I've cacked this
- explanation up enough.
-
- Chris Johnson
- hbmus009@csun.edu
-
-